//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2024 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto-codegenerator.
// DO NOT EDIT.

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
@_exported import SotoCore

/// Service object for interacting with AWS MarketplaceDeployment service.
///
/// The AWS Marketplace Deployment Service supports the Quick Launch experience, which is a deployment option for software as a service (SaaS) products.  Quick Launch simplifies and reduces the time, resources, and steps required to configure, deploy, and launch a products.  The AWS Marketplace Deployment Service provides sellers with a secure method for passing deployment parameters, such as  API keys and external IDs, to buyers during the Quick Launch experience.
public struct MarketplaceDeployment: AWSService {
    // MARK: Member variables

    /// Client used for communication with AWS
    public let client: AWSClient
    /// Service configuration
    public let config: AWSServiceConfig

    // MARK: Initialization

    /// Initialize the MarketplaceDeployment client
    /// - parameters:
    ///     - client: AWSClient used to process requests
    ///     - region: Region of server you want to communicate with. This will override the partition parameter.
    ///     - partition: AWS partition where service resides, standard (.aws), china (.awscn), government (.awsusgov).
    ///     - endpoint: Custom endpoint URL to use instead of standard AWS servers
    ///     - middleware: Middleware chain used to edit requests before they are sent and responses before they are decoded 
    ///     - timeout: Timeout value for HTTP requests
    ///     - byteBufferAllocator: Allocator for ByteBuffers
    ///     - options: Service options
    public init(
        client: AWSClient,
        region: SotoCore.Region? = nil,
        partition: AWSPartition = .aws,
        endpoint: String? = nil,
        middleware: AWSMiddlewareProtocol? = nil,
        timeout: TimeAmount? = nil,
        byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator(),
        options: AWSServiceConfig.Options = []
    ) {
        self.client = client
        self.config = AWSServiceConfig(
            region: region,
            partition: region?.partition ?? partition,
            serviceName: "MarketplaceDeployment",
            serviceIdentifier: "deployment-marketplace",
            signingName: "aws-marketplace",
            serviceProtocol: .restjson,
            apiVersion: "2023-01-25",
            endpoint: endpoint,
            errorType: MarketplaceDeploymentErrorType.self,
            middleware: middleware,
            timeout: timeout,
            byteBufferAllocator: byteBufferAllocator,
            options: options
        )
    }





    // MARK: API Calls

    /// Lists all tags that have been added to a deployment parameter resource.
    @Sendable
    @inlinable
    public func listTagsForResource(_ input: ListTagsForResourceRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> ListTagsForResourceResponse {
        try await self.client.execute(
            operation: "ListTagsForResource", 
            path: "/tags/{resourceArn}", 
            httpMethod: .GET, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Lists all tags that have been added to a deployment parameter resource.
    ///
    /// Parameters:
    ///   - resourceArn: The Amazon Resource Name (ARN) associated with the deployment parameter resource you want to list tags on.
    ///   - logger: Logger use during operation
    @inlinable
    public func listTagsForResource(
        resourceArn: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> ListTagsForResourceResponse {
        let input = ListTagsForResourceRequest(
            resourceArn: resourceArn
        )
        return try await self.listTagsForResource(input, logger: logger)
    }

    /// Creates or updates a deployment parameter and is targeted by catalog and agreementId.
    @Sendable
    @inlinable
    public func putDeploymentParameter(_ input: PutDeploymentParameterRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> PutDeploymentParameterResponse {
        try await self.client.execute(
            operation: "PutDeploymentParameter", 
            path: "/catalogs/{catalog}/products/{productId}/deployment-parameters", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Creates or updates a deployment parameter and is targeted by catalog and agreementId.
    ///
    /// Parameters:
    ///   - agreementId: The unique identifier of the agreement.
    ///   - catalog: The catalog related to the request. Fixed value: AWSMarketplace
    ///   - clientToken: The idempotency token for deployment parameters. A unique identifier for the new version.  This field is not required if you're calling using an AWS SDK. Otherwise, a clientToken must be provided with the request.
    ///   - deploymentParameter: The deployment parameter targeted to the acceptor of an agreement for which to create the AWS Secret Manager resource.
    ///   - expirationDate: The date when deployment parameters expire and are scheduled for deletion.
    ///   - productId: The product for which AWS Marketplace will save secrets for the buyer’s account.
    ///   - tags: A map of key-value pairs, where each pair represents a tag saved to the resource. Tags will only be applied for create operations, and they'll be ignored if the resource already exists.
    ///   - logger: Logger use during operation
    @inlinable
    public func putDeploymentParameter(
        agreementId: String,
        catalog: String,
        clientToken: String? = PutDeploymentParameterRequest.idempotencyToken(),
        deploymentParameter: DeploymentParameterInput,
        expirationDate: Date? = nil,
        productId: String,
        tags: [String: String]? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> PutDeploymentParameterResponse {
        let input = PutDeploymentParameterRequest(
            agreementId: agreementId, 
            catalog: catalog, 
            clientToken: clientToken, 
            deploymentParameter: deploymentParameter, 
            expirationDate: expirationDate, 
            productId: productId, 
            tags: tags
        )
        return try await self.putDeploymentParameter(input, logger: logger)
    }

    /// Tags a resource.
    @Sendable
    @inlinable
    public func tagResource(_ input: TagResourceRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> TagResourceResponse {
        try await self.client.execute(
            operation: "TagResource", 
            path: "/tags/{resourceArn}", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Tags a resource.
    ///
    /// Parameters:
    ///   - resourceArn: The Amazon Resource Name (ARN) associated with the resource you want to tag.
    ///   - tags: A map of key-value pairs, where each pair represents a tag present on the resource.
    ///   - logger: Logger use during operation
    @inlinable
    public func tagResource(
        resourceArn: String,
        tags: [String: String]? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> TagResourceResponse {
        let input = TagResourceRequest(
            resourceArn: resourceArn, 
            tags: tags
        )
        return try await self.tagResource(input, logger: logger)
    }

    /// Removes a tag or list of tags from a resource.
    @Sendable
    @inlinable
    public func untagResource(_ input: UntagResourceRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> UntagResourceResponse {
        try await self.client.execute(
            operation: "UntagResource", 
            path: "/tags/{resourceArn}", 
            httpMethod: .DELETE, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Removes a tag or list of tags from a resource.
    ///
    /// Parameters:
    ///   - resourceArn: The Amazon Resource Name (ARN) associated with the resource you want to remove the tag from.
    ///   - tagKeys: A list of key names of tags to be removed.
    ///   - logger: Logger use during operation
    @inlinable
    public func untagResource(
        resourceArn: String,
        tagKeys: [String],
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> UntagResourceResponse {
        let input = UntagResourceRequest(
            resourceArn: resourceArn, 
            tagKeys: tagKeys
        )
        return try await self.untagResource(input, logger: logger)
    }
}

extension MarketplaceDeployment {
    /// Initializer required by `AWSService.with(middlewares:timeout:byteBufferAllocator:options)`. You are not able to use this initializer directly as there are not public
    /// initializers for `AWSServiceConfig.Patch`. Please use `AWSService.with(middlewares:timeout:byteBufferAllocator:options)` instead.
    public init(from: MarketplaceDeployment, patch: AWSServiceConfig.Patch) {
        self.client = from.client
        self.config = from.config.with(patch: patch)
    }
}
